package top.yehot.kettle.boot.controller;

import javax.validation.Valid;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import top.yehot.cmm.util.spring.anns.ResponseResult;
import top.yehot.kettle.boot.core.SysConst;
import top.yehot.kettle.boot.models.entity.GlobalParam;
import top.yehot.kettle.boot.models.vo.param.GlobalParamAddVO;
import top.yehot.kettle.boot.models.vo.param.GlobalParamEditVO;
import top.yehot.kettle.boot.models.vo.param.GlobalParamPageVO;
import top.yehot.kettle.boot.service.GlobalParamService;

/**
 * 参数管理
 * 
 * @author lquan
 * @date 2022年6月3日 下午4:51:12
 */
@Api(tags = "参数管理")
@RestController
@RequestMapping(SysConst.VERSION + "/param")
@AllArgsConstructor
@ResponseResult
public class GlobalParamController {
	
	private final GlobalParamService globalParamService;

	@ApiOperation("参数列表（分页）")
	@PostMapping("page")
	public IPage<GlobalParam> page(@RequestBody GlobalParamPageVO param) {
		return globalParamService.page(param);
	}
	
	@ApiOperation("参数新增")
	@PostMapping("add")
	public void add(@RequestBody @Valid GlobalParamAddVO param) {
		globalParamService.add(param);
	}
	
	@ApiOperation("根据ID查询参数")
	@GetMapping("getById")
	public GlobalParam getById(@RequestParam("id") Integer id) {
		return globalParamService.getById(id);
	}
	
	@ApiOperation("参数编辑")
	@PostMapping("edit")
	public void edit(@RequestBody @Valid GlobalParamEditVO param) {
		globalParamService.edit(param);
	}
	
	@ApiOperation("参数删除")
	@GetMapping("delete")
	public void delete(@RequestParam("id") Integer id) {
		globalParamService.delete(id);
	}
	
}
